/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vita;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author Family
 */
public class Person implements Serializable {
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    private String name;
    private Integer birthYear;
    private Integer deathYear;
    private String commemorationMonth;
    private String commemorationDay;
    private String tags;
    private String birthLocation;
    private String lifeLocation;
    private String deathLocation;
    private String relicsLocation;
    private String lifeStory;
    private String connections;
    private ArrayList<String> icons;

    public Person() {
    }

    public Person (String name, int birthYear, int deathYear, String commemorationMonth, String commemorationDay, String tags,
                   String birthLocation, String lifeLocation, String deathLocation, String relicsLocation,
                   String lifeStory, String connections, ArrayList<String> icons) {
        this.name=name;
        this.birthYear=birthYear;
        this.deathYear=deathYear;
        this.commemorationMonth=commemorationMonth;
        this.commemorationDay=commemorationDay;
        this.tags=tags;
        this.birthLocation=birthLocation;
        this.lifeLocation=lifeLocation;
        this.deathLocation=deathLocation;
        this.relicsLocation=relicsLocation;
        this.lifeStory=lifeStory;
        this.connections=connections;
        this.icons=icons;
    }

    public Person(Person p) {
        this.name=p.name;
        this.birthYear=p.birthYear;
        this.deathYear=p.deathYear;
        this.commemorationMonth=p.commemorationMonth;
        this.commemorationDay=p.commemorationDay;
        this.tags=p.tags;
        this.birthLocation=p.birthLocation;
        this.lifeLocation=p.lifeLocation;
        this.deathLocation=p.deathLocation;
        this.relicsLocation=p.relicsLocation;
        this.lifeStory=p.lifeStory;
        this.connections=p.connections;
        this.icons=p.icons;
    }

    public Person clone() {
        return new Person(name, birthYear, deathYear, commemorationMonth, commemorationDay, tags,
                               birthLocation,lifeLocation, deathLocation, relicsLocation,
                               lifeStory, connections, icons);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        String oldName = this.name;
        this.name = name;
        changeSupport.firePropertyChange("name", oldName, name);
    }

    public Integer getBirthYear() {
        return birthYear;
    }

    public void setBirthYear(Integer birthYear) {
        Integer oldBirthYear = this.birthYear;
        this.birthYear = birthYear;
        changeSupport.firePropertyChange("birthYear", oldBirthYear, birthYear);
    }

    public Integer getDeathYear() {
        return deathYear;
    }

    public void setDeathYear(Integer deathYear) {
        Integer oldDeathYear = this.deathYear;
        this.deathYear = deathYear;
        changeSupport.firePropertyChange("deathYear", oldDeathYear, deathYear);
    }

    public String getCommemorationMonth() {
        return commemorationMonth;
    }

    public void setCommemorationMonth(String commemorationMonth) {
        String oldCommemorationMonth = this.commemorationMonth;
        this.commemorationMonth = commemorationMonth;
        changeSupport.firePropertyChange("commemorationMonth",oldCommemorationMonth, commemorationMonth);
    }
    public String getCommemorationDay() {
        return commemorationDay;
    }

    public void setCommemorationDay(String commemorationDay) {
        String oldCommemorationDay = this.commemorationDay;
        this.commemorationDay = commemorationDay;
        changeSupport.firePropertyChange("commemorationDay",oldCommemorationDay, commemorationDay);
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        String oldTags = this.tags;
        this.tags = tags;
        changeSupport.firePropertyChange("tags",oldTags, tags);
    }

    public String getBirthLocation() {
        return birthLocation;
    }

    public void setBirthLocation(String birthLocation) {
        String oldBirthLocation = this.birthLocation;
        this.birthLocation = birthLocation;
        changeSupport.firePropertyChange("birthLocation", oldBirthLocation, birthLocation);
    }

    public String getLifeLocation() {
        return lifeLocation;
    }

    public void setLifeLocation(String lifeLocation) {
        String oldLifeLocation = this.lifeLocation;
        this.lifeLocation = lifeLocation;
        changeSupport.firePropertyChange("lifeLocation", oldLifeLocation, lifeLocation);
    }

    public String getDeathLocation() {
        return deathLocation;
    }

    public void setDeathLocation(String deathLocation) {
        String oldDeathLocation = this.deathLocation;
        this.deathLocation = deathLocation;
        changeSupport.firePropertyChange("deathLocation", oldDeathLocation, deathLocation);
    }

    public String getRelicsLocation() {
        return relicsLocation;
    }

    public void setRelicsLocation(String relicsLocation) {
        String oldRelicsLocation = this.relicsLocation;
        this.relicsLocation = relicsLocation;
        changeSupport.firePropertyChange("relicsLocation", oldRelicsLocation, relicsLocation);
    }

    public String getLifeStory() {
        return lifeStory;
    }

    public void setLifeStory(String lifeStory) {
        String oldLifeStory = this.lifeStory;
        this.lifeStory = lifeStory;
        changeSupport.firePropertyChange("lifeStory", oldLifeStory, lifeStory);
    }

    public String getConnections() {
        return connections;
    }

    public void setConnections(String connections) {
        String oldConnections = this.connections;
        this.connections = connections;
        changeSupport.firePropertyChange("connections", oldConnections, connections);
    }


    public void addIcon(String filePath) {
        icons.add(filePath);
    }

    public ArrayList<String> getIcons() {
        return icons;
    }

    public void setIcons(ArrayList<String> icons) {
        ArrayList<String> oldIcons = this.icons;
        this.icons = icons;
        changeSupport.firePropertyChange("icon", oldIcons, icons);
    }

/*
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
*/

    @Override
    public String toString() {
        return "Person:   name="+name+" birthYear="+birthYear;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
